|
The GNU Multiple Precision Arithmetic Library (GMP) is a free library for arbitrary-precision arithmetic, operating on signed integers, rational numbers, and floating point numbers.〔(【引用サイトリンク】 title=What is GMP? )〕 There are no practical limits to the precision except the ones implied by the available memory in the machine GMP runs on (operand dimension limit is 232-1 bits on 32-bit machines and 237 bits on 64-bit machines). GMP has a rich set of functions, and the functions have a regular interface. The basic interface is for C but wrappers exist for other languages including Ada, C++, C#, OCaml, Perl, PHP, Python and R. In the past, the Kaffe Java virtual machine used GMP to support Java built-in arbitrary precision arithmetic. This feature has been removed from recent releases, causing protests from people who claim that they used Kaffe solely for the speed benefits afforded by GMP. As a result, GMP support has been added to GNU Classpath.〔(【引用サイトリンク】 title=GNU Classpath 0.98 "Better Late Than Never" )〕 The main target applications of GMP are cryptography applications and research, Internet security applications, and computer algebra systems. GMP aims to be faster than any other bignum library for all operand sizes. Some important factors in doing this are: * Using full words as the basic arithmetic type. * Using different algorithms for different operand sizes; algorithms that are faster for very big numbers are usually slower for small numbers. * Highly optimized assembly language code for the most important inner loops, specialized for different processors. The first GMP release was made in 1991. It is constantly developed and maintained.〔 GMP is part of the GNU project (although its website being off gnu.org may cause confusion), and is distributed under the GNU Lesser General Public License (LGPL). GMP is used for integer arithmetic in many computer algebra systems such as Mathematica〔(【引用サイトリンク】 title=The Mathematica Kernel: Issues in the Design and Implementation )〕 and Maple.〔(【引用サイトリンク】 title= The GNU Multiple Precision (GMP) Library )〕 It is also used in the Computational Geometry Algorithms Library (CGAL) because geometry algorithms tend to 'explode' when using ordinary floating point CPU math. GMP is needed to build the GNU Compiler Collection (GCC).〔GCC uses the MPFR library, which in turn relies on GMP. (【引用サイトリンク】 title=GCC 4.3 Release Series: Changes, New Features, and Fixes )〕 == Examples == Here is an example of C code showing the use of the GMP library to multiply and print large numbers: #include #include int main(void) This code calculates the value of 7612058254738945 × 9263591128439081. Compiling and running this program gives this result. (The -lgmp flag is used if compiling on Unix-type systems.) 7612058254738945 * 9263591128439081 -------------------- 70514995317761165008628990709545 For comparison, one can write instead the following equivalent C++ program. (The -lgmpxx -lgmp flags are used if compiling on Unix-type systems.) #include #include int main() 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「GNU Multiple Precision Arithmetic Library」の詳細全文を読む スポンサード リンク
|